var data1 = [
  {
    id: 1,
    field1: '2015.02.20',
    field2: '张飞',
    field3: '1',
    field4: '工程使用',
    field5: '11',
  },
];

var data2 = [
  {
    id: 1,
    field1: '2015.02.20',
    field2: '徐三',
    field3: '1',
    field4: '12',
    field5: '',
  },
];

/**
 * 根据条件查询
 */
function queryByCondition() {
  var param = {};
  $('#table1').bootstrapTable('refreshOptions', {
    queryParams: function (params) {
      var obj = {
        size: params.limit,
        page: params.offset / params.limit + 1,
      };
      $.extend(param, obj);
      return JSON.stringify(param);
    }
  });
};

/**
 * 表格初始化
 */
function initTable(newParams) {
  var $table = $('#table1');
  $table.bootstrapTable({
    url: "",
    method: 'POST',
    pagination: true,
    pageSize: 10,
    sidePagination: 'server',//设置为服务器端分页
    queryParams: function (params) {
      // 请求参数
      var obj = {
        size: params.limit,
        page: params.offset / params.limit + 1
      };
      return JSON.stringify(obj);
    }
  });
};

$(document).ready(function() {
  var $table = $('#table1');
  $table.bootstrapTable({
    data: data1,
    pagination: true
  });

  var $table = $('#table2');
  $table.bootstrapTable({
    data: data2,
    pagination: true
  });

  initNavTab(function(index){
    console.log(index);
  });
});
